package com.emode.util;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;

public class CollectionUtil
{
  public static <K, V> HashMap<K, V> newHashMap()
  {
    return new HashMap();
  }

  public static <K, V> HashMap<K, V> newHashMap(int size)
  {
    return new HashMap();
  }

  public static <K, V> ConcurrentHashMap<K, V> newConcurrentHashMap()
  {
    return new ConcurrentHashMap();
  }

  public static <K, V> ConcurrentHashMap<K, V> newConcurrentHashMap(int size)
  {
    return new ConcurrentHashMap(size);
  }

  public static <T> ArrayList<T> newArrayList()
  {
    return new ArrayList();
  }

  public static <T> ArrayList<T> newArrayList(int size)
  {
    return new ArrayList(size);
  }

  public static <T> HashSet<T> newHashSet()
  {
    return new HashSet();
  }

  public static <T> HashSet<T> newHashSet(int size)
  {
    return new HashSet(size);
  }

  public static <T> TreeSet<T> newTreeSet()
  {
    return new TreeSet();
  }

 /* public static <K, V> Map<K, V> sortMap(Map<K, V> map, Comparator<Map.Entry<K, V>> compator)
  {
    Map result = new LinkedHashMap();
    List<Object> entries = new ArrayList(map.entrySet());
    Collections.sort(entries, compator);
    for (Map.Entry entry : entries) {
      result.put(entry.getKey(), entry.getValue());
    }
    return result;
  }*/

  public static <E> boolean isEmpty(Collection<E> c)
  {
    return ((null == c) || (c.isEmpty()));
  }

  public static <K, V> boolean isEmpty(Map<K, V> map)
  {
    return ((null == map) || (map.isEmpty()));
  }

  public static <T> boolean isEmpty(T[] arr)
  {
    return ((null == arr) || (arr.length == 0));
  }
}